const db = require('../config/db');
const Sequelize = db.sequelize;
const Op = Sequelize.Op;
const Index = Sequelize.import('../schema/index');


Index.sync({force: false});

class IndexModel {
    /**
     * 更新文章数据
     * @param id 文章ID
     * @param data 文章更新的属性参数
     */
    static async update(id, data) {
        return await Index.update(data, {
            where: {
                id
            },
            fields: ['school_content', 'school_content_img', 'notice_article', 'notice_category', 'banner','consultation', 'consultation_b', 'service_items','service_items_b', 'end_date', 'img_model1', 'img_model2', 'xtp_model1', 'xtp_model2','schools','educations','banner1','logo','cr_education']
        });
    }

    /**
     * 获取文章详情数据
     * @param id  文章ID
     * @returns {Promise<Model>}
     */
    static async detail(id) {
        return await Index.findOne({
            where: {
                id
            }
        })
    }
}

module.exports = IndexModel
